home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / util / libs / mpega_libmad.lha / mpega_libmad / startup_pup.c < prev    next >
C/C++ Source or Header  |  2001-11-15  |  2KB  |  83 lines

  1. // =======================================================================
  2. // ppc side communication dispatcher
  3. // (c)1998 by Jacek Cybularczyk (NOE/VenusArt)
  4. // slightly modified for specific use by Sigbjørn (CISC) Skjæret
  5. // =======================================================================
  6.  
  7. #include "library_base.h"
  8.  
  9. #include <exec/memory.h>
  10. #include <utility/tagitem.h>
  11.  
  12. #include <powerup/ppclib/object.h>
  13. #include <powerup/ppclib/interface.h>
  14. #include <powerup/ppclib/message.h>
  15. #include <powerup/ppclib/tasks.h>
  16.  
  17. #include <proto/exec.h>
  18. #include <proto/dos.h>
  19. #include <powerup/gcclib/powerup_protos.h>
  20.  
  21. #include "support.h"
  22.  
  23. extern APTR __LibFuncTable[];
  24.  
  25. void MainEntry(void)
  26. {
  27.     APTR ElfObject;
  28.     APTR PPCPort;
  29.     APTR CallPPCMsg;
  30.     ULONG (*function)(ULONG, ULONG);
  31.     struct CallPPCData *CallPPCData;
  32.     struct StartupData *StartupData;
  33.  
  34.     StartupData = (struct StartupData *)PPCGetTaskAttr(PPCTASKTAG_STARTUP_MSGDATA);
  35.     ElfObject = StartupData->ElfObject;
  36.  
  37.     if ((PPCPort = (APTR)PPCGetTaskAttr(PPCTASKTAG_MSGPORT)))
  38.     {
  39.         BOOL Terminated = FALSE;
  40.  
  41.         do {
  42.             PPCWaitPort(PPCPort);
  43.  
  44.             if ((CallPPCMsg = PPCGetMessage(PPCPort)))
  45.             {
  46.                 CallPPCData = (struct CallPPCData *)PPCGetMessageAttr(CallPPCMsg, PPCMSGTAG_DATA);
  47.  
  48.                 switch (CallPPCData->Type)
  49.                 {
  50.                     case MSGTYPE_CALL:
  51.                         function = (ULONG (*)(ULONG, ULONG))__LibFuncTable[CallPPCData->PPCLVO];
  52.                         CallPPCData->Return = function(CallPPCData->Args[0], CallPPCData->Args[1]);
  53.                         break;
  54.  
  55.                     case MSGTYPE_INIT:
  56.                         CallPPCData->Return = InitSupport();
  57.                         Terminated = TRUE;
  58.                         break;
  59.  
  60.                     case MSGTYPE_HELLO:
  61.                         CallPPCData->Return = 1;
  62.                         break;
  63.  
  64.                     case MSGTYPE_REMOVE:
  65.                         RemoveSupport();
  66.  
  67.                     /* Fall through */
  68.  
  69.                     case MSGTYPE_GOODBYE:
  70.                         Terminated = TRUE;
  71.                         break;
  72.  
  73.                     default:
  74.                         break;
  75.                 }
  76.  
  77.                 PPCCacheFlushAll();
  78.                 PPCReplyMessage(CallPPCMsg);
  79.             }
  80.         } while (!Terminated);
  81.     }
  82. }
  83.